<template>
  <div>
    <p class="recommend-title">为你推荐</p>
    <div class="recommend-list">
      <div class="recommend-item" v-for="item in recommendList" :key="item.id">
        <img :src="item.imageHost + item.mainImage" />
        <p>
          {{ item.subtitle }}
        </p>
        <i>￥ {{ item.price }}</i>
      </div>
    </div>
  </div>
</template>

<script>
import { getRecommend } from "@/api";

export default {
  data() {
    return {
      recommendList: [],
    };
  },
  created() {
    this.recommendInfo();
  },
  methods: {
    recommendInfo() {
      getRecommend((res) => {
        // console.log(res);
        this.recommendList = res.data;
      });
    },
  },
};
</script>

<style lang="scss" scoped>
@import "@/common/style/mixin.scss";

.recommend-title {
  width: 100%;
  height: 90px;
  padding-left: 20px;
  line-height: 90px;
  background: #fff;
  @include boxSizing;
}

.recommend-list {
  display: flex;
  flex-shrink: 0;
  flex-wrap: wrap;
  width: 100%;
  margin-top: 30px;
  padding-bottom: 150px;
  @include boxSizing;
  background: #fff;

  .recommend-item {
    display: flex;
    flex-direction: column;
    width: 50%;
    padding: 20px;
    @include boxSizing;
    border-bottom: 1px solid #dcdcdc;

    &:nth-child(2n-1) {
      border-right: 1px solid #dcdcdc;
    }

    img {
      width: 100%;
      height: 290px;
      margin: 0 auto;
    }

    p {
      height: 60px;
      padding: 20px 0;
      font-size: 26px;
      line-height: 40px;
      color: #333;
      overflow: hidden;
    }

    i {
      font-style: normal;
      font-size: 32px;
      color: $red;
    }
  }
}
</style>